import 'package:fashion_app/config/app.dart';
import 'package:flutter/material.dart';

class TopNav extends StatelessWidget {
  // 假设这里有一个变量来表示是否有未读消息
  final bool hasUnreadMessages;

  // 构造函数，接收是否有未读消息的参数
  const TopNav({Key? key, required this.hasUnreadMessages}) : super(key: key);

  @override
  Widget build(BuildContext context) {
    return Container(
      color: Colors.white,
      child: Padding(
        padding: EdgeInsets.symmetric(horizontal: 16),
        child: Row(
          mainAxisAlignment: MainAxisAlignment.spaceBetween,
          children: [
            CircleAvatar(
              radius: 16, // 半径设置为20，直径即为40，满足40*40的大小要求
              backgroundColor: AppConfig.themeColor,
              child: Image.asset('lib/assets/images/logo.png', width: 18),
            ),
            Row(
              children: [
                // 搜索图标
                IconButton(
                  icon: Icon(Icons.search),
                  onPressed: () {
                    // 跳转搜索页面
                  },
                ),
                // 消息图标
                Stack(
                  children: [
                    IconButton(
                      icon: Icon(Icons.notifications_none),
                      onPressed: () {
                        // TODO 跳转消息中心页面
                      },
                    ),
                    if (hasUnreadMessages)
                      Positioned(
                        right: 10,
                        top: 10,
                        child: Container(
                          width: 8,
                          height: 8,
                          decoration: BoxDecoration(
                            color: Colors.red,
                            borderRadius: BorderRadius.circular(4),
                          ),
                        ),
                      ),
                  ],
                ),
              ],
            ),
          ],
        ),
      ),
    );
  }
}
